package com.zhl.myspringtest.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zhl.myspringtest.entity.Hr;
import com.zhl.myspringtest.service.impl.HrService;
import com.zhl.myspringtest.utils.HrServerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/hr")
public class HrController {

    @Autowired
    public HrService hrService;

    @RequestMapping("/one")
    @GetMapping("/one")
    @PostMapping("/one")
    @PutMapping
    @DeleteMapping
    public Hr selectOne(Long id){
        return hrService.getOne(new LambdaQueryWrapper<Hr>().eq(Hr::getId,id));
    }

    @RequestMapping("/list")
    public List<Hr> selectList(Long id){
        return hrService.list(new LambdaQueryWrapper<Hr>().eq(Hr::getManagerId,id));
    }

    @RequestMapping("/old")
    public void test(Long id){
        HrService hrService1 = HrServerFactory.getInstance();
        hrService1.getOne(new LambdaQueryWrapper<Hr>().eq(Hr::getId,id));
    }
}
